package com.inet.p14_popupwindow;

import androidx.annotation.LongDef;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "wz";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void btnCLick(View view) {

        View content_view = getLayoutInflater().inflate(R.layout.popup_view, null);
//        PopupWindow popupWindow = new PopupWindow(view1,200,100,true);
        PopupWindow popW = new PopupWindow(content_view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        popW.setBackgroundDrawable(getResources().getDrawable(R.drawable.img02));
//        popW.setContentView(content_view);
        popW.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                Log.d(TAG, "onDismiss: popWindow关闭了哈！！");
            }
        });

//        popW.setAnimationStyle(int animateble); //需要xml加载动画，后面学了动画再做
        popW.setTouchable(true);
        popW.setOutsideTouchable(true);
        popW.setFocusable(true);

        popW.showAsDropDown(view, 30,30);

    }

    public void popupBtnClick(View view) {
        Log.d(TAG, "popupBtnClick: 弹框中的按钮被点击了");
    }
}